package test1230am;

public class Test09 {
    public static void main(String[] args) {

        // (9)求数组元素平均值
        int[] arr = {1, 2, 3, 4, 5};
        double sum = 0;
        double avg = 0;
        for (int i=0;i<arr.length;i++) {
            sum += arr[i];
            avg = (double) sum / (double) arr.length;
        }
        System.out.println("平均值为"+avg);
    }
}
